import { h, createVNode } from 'vue';

import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { lang } from 'moment/moment';

/*二次封装 ant-design-vue -modal*/
export function show(modal, types, title, message, ok_fn, cancel_fn) {

    let langs=window.sessionStorage.getItem('langs'||'zh');

   

    if (types == "success") {

        if(langs=='zh'){
            title="系统提示";
    
            message="成功!"
        }else if(langs=='en'){
            title="System tips";

            message="success!"
        }


        return modal.success({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "warning") {

        return modal.warning({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "error") {

        if(langs=='zh'){
            title="系统提示";
    
            message="操作失败"
        }else if(langs=='en'){
            title="System tips";

            message="failed!"
        }



        return modal.warning({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "comfirm") {

        return modal.confirm({
            title: 'Do you Want to delete these items?',
            icon: createVNode(ExclamationCircleOutlined),
            content: createVNode(
                'div',
                {
                    style: 'color:red;',
                },
                message,
            ),
            onOk() {
                if (typeof ok_fn == 'function') {
                    ok_fn()
                }

            },
            onCancel() {

                if (typeof cancel_fn == 'function') {

                    cancel_fn();
                }

            },
            class: 'test',
        });

    }
}

/*二次封装 ant-design-vue -modal*/
export function show_content(modal, types, title, message, ok_fn, cancel_fn) {

    let langs=window.sessionStorage.getItem('langs'||'zh');

   

    if (types == "success") {


        if(langs=='zh'){
            title="系统提示";
    
            message="成功!"+message;
        }else if(langs=='en'){
            title="System tips";

            message="success!"+message;
        }


        return modal.success({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "warning") {

        return modal.warning({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "error") {


        if(langs=='zh'){
            title="系统提示";
    
        }else if(langs=='en'){
            title="System tips";

        }



        return modal.warning({
            title: title,
            content: h('div', {}, [
                h('p', message),
            ]),
        });
    } else if (types == "comfirm") {

        return modal.confirm({
            title: 'Do you Want to delete these items?',
            icon: createVNode(ExclamationCircleOutlined),
            content: createVNode(
                'div',
                {
                    style: 'color:red;',
                },
                message,
            ),
            onOk() {
                if (typeof ok_fn == 'function') {
                    ok_fn()
                }

            },
            onCancel() {

                if (typeof cancel_fn == 'function') {

                    cancel_fn();
                }

            },
            class: 'test',
        });

    }
}